Copyright (c) 1999 Massachusetts Institute of Technology

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see https://gnu.org/licenses or write
to:
  Free Software Foundation, Inc.
  51 Franklin Street, Fifth Floor
  Boston, MA 02110-1301
  USA
------------------------------

;Archive device format:

;The first page of an archive device file is its directory.
;The remaining pages are data.

;The directory may not even be looked at unless the archive is "locked".
.SEE LOCK,UNLOCK	;Only one ARCDEV can lock a given archive at a time.
;Shuffling the directory should not be done in place, even when it is locked.
;Instead, use DIRGET to make a copy and DIRPUT to store the copy back in.
;When a file is open, the address of its data area is remembered in FILADR.
;The data area of a file never moves, and the file can be open only in one
;direction at a time, so reading or writing the data area requires no interlocking.

;The format of the archive device directory is approximately that of
;an I.T.S. UFD.  The differences are:

;In the fixed header, word 0 (UDESCP) contains SIXBIT /ARC1!!/
;Word 1 points to the beginning of the name area, as in UFDs.
;Word 2 points to the end of the data area.
;Word 3 is used to tell when the archive needs to be cleaned
;  because it is being touched for the first time since the system came up.
;Word 4 contains what is supposed to be the creation date of the archive.
;  Since locking the archive device clobbers the creation date,
;  we store it here so we can restore it after clobbering it.
;Word 5 similarly stores the dumped bit.

;There is nothing analogous to the "descriptors" in a disk UFD.

		;Random info in UFD
UDESCP==0	;SIXBIT /ARC1!!/
UDNAMP==1	;Address in directory of first filename block.
UDDATP==2	;Address of first free word past data area of last file.
UDINIT==3	;Time of startup of last run of system during which this
		;archive was cleaned (ARCCLN).  If not same as startup time
		;of this run of the system, we must do ARCCLN.
UDCRDT==4	;This word holds what ought to be the creation date
		;of the archive device file itself.
		;0 => this archive antedates the UDCRDT word, in which
		;case it gets set from today's date.
UDDMPB==5	;This is like UDCRDT but stores the dumped bit.

UDNMIN==10	;If UDNAMP is less than this, there is no room for another filename block.

;In each filename block, the UNFN1, UNFN2, UNDATE and UNREF words are
;just as in UFDs.  The UNRNDM word is slightly different:

LUNBLK==5	;Number of words in each filename block.
UNFN1==0	;First file name.
UNFN2==1	;Second file name.
UNRNDM==2	;All kinds of random info:
		;The RH is the address in the file of the start of the file's data area header.
		;The LH contains these bits:
	UNWRIT==4		;Open for writing.  Not actually maintained in the archive,
				;Just reflected to the user when he reads ARC:.FILE. (DIR).
	UNCDEL==20		;Delete this file when it is closed.
	UNIGFL==24		;Bits to ignore file
	UNWRDC==301200,,	;Word count of last block mod 2000.
				;This information really lives in UHWCNT, and is just reflected
				;here when the user reads the image directory.
UNDATE==3	;Date and time file last modified.
	UNTIM==2200,,		;Compacted time of creation
	UNYMD==222000,,		;Y,M,D of creation
	UNMON==270400,,		;Month
	UNDAY==220500,,		;Day
	UNYRB==330700,,		;Year
UNREF==4	;Reference date same as left half of undate
	UNREFD==222000,,	;Reference date byte pointer
	UNAUTH==111100,,	;MFD index of author, all 1=> no directory.
	UNBYTE==001100,,	;File byte size and length info.
		;LET S=BITS PER BYTE, C=COUNT OF UNUSED BYTES IN LAST WD
		;400+100xS+C	S=1 TO 3	C=0 TO 35.
		;200+20xS+C	S=4 TO 7	C=0 TO 8
		;44+4xS+C	S=8 TO 18.	C=0 TO 3
		;44-S		S=19. TO 36.	C=0
		;NOTE THAT OLD FILES HAVE UNBYTE=0 => S=36.


;The data of a file starts with two words of header information:
UHWCNT==0	;Total length of the file's data, including header, in words.
UHREFC==1	;RH: Number of archives using the file, in either direction.
		;LH: -1 if file open for writing.
UHNAMP==2	;Unused
UHBLEN==3	;Length of this header;  offset to 1st actual data word.

